//发布者
class Journal{
    constructor(){
        this.list = []
    }
    //订阅
    subscribe(user){
        this.list.push(user)
    }
    //发布
    submit(data){
        this.list.forEach(item=>item.update(data))
    }

}
class Subscribe{
    constructor(name){
        this.name = name
    }
    update(data){
        console.log(`${this.name}:${data}`);
    }
}
const J1 = new Journal()
const s1 = new Subscribe('李四')
const s2 = new Subscribe('张三')
const s3 = new Subscribe('Joker')
J1.subscribe(s1)
J1.subscribe(s2)
J1.subscribe(s3)
J1.submit('今天真的 ')
